/*! \file textline.h	
	This is the header file for textline.cpp
	
	This contains the TextLine class
*/

#ifndef TEXTLINE_H
#define TEXTLINE_H

#include <GL/glfw.h> // for constants
#include <iostream>
#include "textcomp.h"
#include "guiconstants.h"
#include "listener.h"
#include "game.h"
#include "guiclass.h"
using namespace std;

/**
	\class TextLine

	This represents a single-line text input.

*/
class TextLine : public TextComponent, public KeyListener {
private:
	/**
	* This represents the width discounting the border.
	* If a border-side has a width of 4, and you set the "w" of this
	* Component to be 200, then widthWithoutBorder will be 192.
	*/
	int widthWithoutBorder;

private:
	/**
	* This function is used by keyDown to move the cursor over one word
	*/
	int ctrlLeft();	

	/**
	* This function is used by keyDown to move the cursor over one word
	*/
	int ctrlRight();
public:
	/**
	* Constructor - this will add itself as a listener so that keypresses and such will work
	*/
	TextLine( Component* Parent );

	/**
	* This comes from being a listener and allows the user to type in this field
	*/
	virtual void keyDown(Event e);


	void performAction(); // tell the listeners attached to this that this button was clicked
	void resetBuffer(); // sets buffer to blank and all things that go with it to 0

	/**
	* This comes from being a listener, but it is currently unused
	*/
	virtual void keyUp(Event e);
	
	/**
	* This comes from its inheritance, but it is currently unused
	*/
	virtual void update() {}
		
	/**
	* This draws the text field
	*/
	virtual void draw();
		
	/**
	* This not only sets the width inherited from Component, but also
	* sets the widthWithoutBorder variable, so that we know how much
	* room can be used for text on this component.
	*/
	void setSize( int newW, int newH );	
		
};



#endif
